<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::group(['middleware' => 'auth'], function ($r) {
    /**
     * @var $r \Route
     */
    $r->group(['prefix' => 'public'], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('upload', 'PublicController@upload')->withoutMiddleware('auth');
    });

    $r->group(['prefix' => 'home'], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('/', 'HomeController@index');
        $r->post('category', 'HomeController@category');
        $r->post('article', 'HomeController@article');
    });

    $r->group(['prefix' => 'goods'], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('list', 'GoodsController@getList');
        $r->post('detail', 'GoodsController@getDetail')->middleware('user');
        $r->post('category-list','GoodsController@categoryList');


    });

    $r->post('user/login', 'UserController@login')->withoutMiddleware('auth');


    $r->group(['prefix' => 'user', 'middleware' => ['user']], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('center', 'UserController@center');
        $r->post('user-msg', 'UserController@userMsg');
        $r->post('edit-user-msg', 'UserController@editUserMsg')->withoutMiddleware('user');
        $r->post('add-behavior', 'UserController@addBehavior');
        $r->post('behavior-list', 'UserController@behaviorList');
        $r->post('delete-behavior', 'UserController@deleteBehavior');
        $r->post('address-list', 'UserController@addressList');
        $r->post('edit-address','UserController@editAddress');
        $r->post('delete-address','UserController@deleteAddress');
        $r->post('share-code','UserController@shareCodeList');
        $r->post('get-phone','UserController@getUserPhone');
        $r->post('withdraw','UserController@withdraw');

    });

    $r->group(['prefix' => 'order', 'middleware' => ['user']], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('add-cart', 'OrderController@addCart');
        $r->post('delete-cart', 'OrderController@deleteCart');
        $r->post('cart-list','OrderController@cartList');
        $r->post('cart-count','OrderController@cartCount');
        $r->post('cart-preview','OrderController@cartPreview');
        $r->post('submit-preview','OrderController@submitPreview');
        $r->post('submit','OrderController@submit');
        $r->post('confirm-pay','OrderController@confirmPay');
        $r->post('cancel','OrderController@cancel');
        $r->post('list','OrderController@orderList');
        $r->post('express','OrderController@orderExpress');
        $r->post('confirm-collect','OrderController@confirmCollect');
        $r->post('detail','OrderController@orderDetail');


        $r->post('notify','OrderController@notify')->withoutMiddleware(['user', 'auth']);

    });

    $r->group(['prefix' => 'partner', 'middleware' => ['user']], function ($r){
        /**
         * @var $r \Route
         */
        $r->post('order-submit', 'PartnerController@orderSubmit');
        $r->post('order-notify', 'PartnerController@orderNotify')->withoutMiddleware(['user', 'auth']);
        $r->post('team', 'PartnerController@myTeam');
        $r->post('index', 'PartnerController@index');

    });

});